﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OracleClient;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Input;
using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Database;
using ReflectionStudio.Core.Events;
using ReflectionStudio.Core.Helpers;

namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for SETUPABON.xaml
    /// </summary>
    public partial class SETUPABON : DocumentBase
    {
        public INTEXDataSet setUI;
        DataSet setDISPO = new DataSet();
        INTEXAV95Data m_Data;
        public OracleConnection OracleDB;
        public OracleCommand orlReadCommand = new OracleCommand();
        public IntexReptServBLClient proxy;
        private Dictionary<string, object> dicParamater;
        string setID = "DST01";
        public SETUPABON()
        {
            InitializeComponent();
            setUI = (INTEXDataSet)TryFindResource("iNTEXDataSet");
            this.Name = "参数设定";
            this.Title = "参数设定";
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
               
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public override void SetUp(Dictionary<string, object> dicParamater)
        {
            try
            {
                setUI = (INTEXDataSet)TryFindResource("iNTEXDataSet");
                using (new LongOperation(this, "读取符合条件的记录"))
                {
                    base.SetUp(dicParamater);
                    InitializeComponent();
                    this.dicParamater = dicParamater;
                    OracleDB = (OracleConnection)dicParamater["OracleDB"];
                    proxy = (IntexReptServBLClient)dicParamater["proxy"];
                    m_Data = new INTEXAV95Data(OracleDB, proxy); 
                    setUI.Clear();
                    setDISPO = m_Data.LoadSetDispo(setID);
                    setUI.Merge(setDISPO);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void btnSaveDATADISPO_Click(object sender, RoutedEventArgs e)
        {
            try
            {
              m_Data. SaveSetDispo(setUI.DATADISPO);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }

        private void btnQueryDATADISPO_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                setUI.Clear();
                setDISPO = m_Data.LoadSetDispo(setID);
                setUI.Merge(setDISPO);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }
    }
}
